
#include <stdio.h>
#include <stdlib.h>
#define OK 1
#define ERROR 0
#define OVERFLOW 0
#define ElemType int
#define Status int
#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10
typedef struct SqStack{
    ElemType *base;
    ElemType *top;
    int stacksize;
}SqStack;
//初始化
Status InitStack(SqStack *S){
    S->base = (ElemType *)malloc(STACK_INIT_SIZE *sizeof(ElemType));
    if(S->base==NULL){
        return ERROR;
    }
    S->top =S->base; //栈顶指针指向栈底
    S->stacksize = STACK_INIT_SIZE;//栈的大小
    return OK;
}
//入栈
Status Push(SqStack *S,ElemType e){
    if(S->top - S->base >= S->stacksize){//栈满，需要扩容
        S->base = (ElemType *)realloc(S->base,(S->stacksize+STACKINCREMENT)*sizeof(ElemType));
        if(S->base==NULL){
            exit(OVERFLOW);
        }
        S->top = S->base + S->stacksize;//更新栈顶指针
        S->stacksize += STACKINCREMENT;//更新栈的大小
    }
    *(S->top) = e;//将元素e入栈
    S->top++;//更新栈顶指针
    return OK;   
}
//出栈
Status Pop(SqStack *S,ElemType *e){
    if(S->top==S->base){
        return ERROR;
    }
    S->top--;//更新栈顶指针
    *e = *(S->top);//将栈顶元素赋值给e
    return OK;
}
//获取栈顶元素
Status GetTop(SqStack *S,ElemType *e){
    if(S->top==S->base){
        return ERROR;
    }   
    *e = *(S->top-1);   
    return OK;
}
//
Status IsEmpty(SqStack *S){
    if(S->base==S->top){
        return OK;
    }
    return 0;
}
int main(){
    SqStack S;
    InitStack(&S);
    int n;
    int x;
    scanf("%d",&n);
    printf("Decimal:%d\n",n);
    while(n>0){
        x=n%8;
        n=n/8;
        Push(&S,x);
    }
    n=0;
    while(S.top!=S.base){
        Pop(&S,&x);
        n=n*10+x;
        
    }
    printf("Octal:%d",n);
}